#include<iostream>
#include<string.h>
using std::cout;
using std::endl;

class Point
{
    //构造函数私有化
public:
    //创建
    static Point* init()
    {
        if(p==nullptr)
        {
            p=new Point(1,2);
        }
        cout<<"init"<<endl;
        return p;
    }
    //修改
    void initnum(const int& a,const int& b)
    {
        _x=a;
        _y=b;
    }

    //销毁
    static void destroy()
    {
        if(p!=nullptr)
        {
            delete p;
            p=nullptr;
        }
        cout<<"destory"<<endl;
    }
    void print()
    {
        cout<<"("<<
            _x<<","<<
            _y<<")"<<endl;
    }

private:
    Point()=default;
    ~Point()=default;
    Point(int a,int b)
    :_x(a)
     ,_y(b)
    {
        cout<<"构造函数"<<endl;
    }
    int _x;
    int _y;
    static Point* p;
};
Point* Point::p=nullptr;


int main()
{
    Point::init()->print();
    Point::init()->initnum(2,3);
    Point::init()->print();
    Point::init()->print();
    Point::init()->print();
    Point::destroy();
}

